﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<%@ Import Namespace="Buffalo.Administration.DAL" %>
<%@ Import Namespace="Buffalo.Administration.Enum" %>
<%@ Import Namespace="Buffalo.SMECommon.DAL" %>
<%@ Import Namespace="Buffalo.SMECommon.Enum" %>
<%@ Import Namespace="Buffalo.Web.Areas.SMECommon" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //bool hasEditPermission = new PermissionDAL().HasPermission(GeneralVar.gLoggedUserName, "SalaryFactor", enuPermissionType.Edit);
                //btnSave.Visible = hasEditPermission;
                //btnAdd.Visible = btnSave.Visible;

                //hidHasEditPermission.Value = hasEditPermission;
            }
            Buffalo.Web.Areas.SMECommon.GeneralVar.gLanguageHelper.ApplyLanguage(this.viewPortSalaryFactor, Buffalo.Web.Areas.SMECommon.CommonManager.GetCurrentCulture(), true);
        }
    </script>
    <script type="text/javascript">
        var commandHandler = function (cmd, record) {
            switch (cmd) {
                case "delete":
                    if (hidHasEditPermission.getValue() != "true")
                        return;
                    Ext.Msg.confirm('Alert', 'Delete SalaryFactor?', function (btn) {
                        if (btn == "yes") {
                            dsSalaryFactor.remove(record);
                            dsSalaryFactor.save();
                        }
                    });
                    break;
            }
        };
    </script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Store ID="dsSalaryFactor" runat="server" RemoteSort="true" UseIdConfirmation="false" AutoLoad="false">
        <Proxy>
            <ext:HttpProxy Url="/SMECommon/Catalog/GetListSalaryFactor/" />
        </Proxy>
        <UpdateProxy>
            <ext:HttpWriteProxy Url="/SMECommon/Catalog/SaveSalaryFactors/" />
        </UpdateProxy>
        <Reader>
            <ext:JsonReader IDProperty="ID" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="ID" />
                    <ext:RecordField Name="GradeName" />
                    <ext:RecordField Name="GradeCode" />
                    <ext:RecordField Name="Scale1" />
                    <ext:RecordField Name="Scale2" />
                    <ext:RecordField Name="Scale3" />
                    <ext:RecordField Name="Scale4" />
                    <ext:RecordField Name="Scale5" />
                    <ext:RecordField Name="Scale6" />
                    <ext:RecordField Name="Scale7" />
                    <ext:RecordField Name="Scale8" />
                    <ext:RecordField Name="Scale9" />
                    <ext:RecordField Name="Scale10" />
                    <ext:RecordField Name="Scale11" />
                    <ext:RecordField Name="Scale12" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <BaseParams>
            <ext:Parameter Name="limit" Value="15" Mode="Raw" />
            <ext:Parameter Name="start" Value="0" Mode="Raw" />
            <ext:Parameter Name="dir" Value="ASC" />
            <ext:Parameter Name="sort" Value="GradeName" />
            <ext:Parameter Name="withDefaultItem" Value="false"  Mode="Value"/> 
            <ext:Parameter Name="cboCriteria" Value="#{cboCriteria}.getValue()" Mode="Raw" />
            <ext:Parameter Name="txtSearchText" Value="#{txtSearchText}.getValue()" Mode="Raw" /> 
        </BaseParams>
        <SortInfo Field="GradeName" Direction="ASC" />
    </ext:Store>

    <ext:Viewport ID="viewPortSalaryFactor" runat="server" Layout="fit">
        <Items>
            <ext:GridPanel ID="GridPanel1" runat="server" Header="false" Border="false" TrackMouseOver="true"
                AutoExpandColumn="Scale12" StoreID="dsSalaryFactor">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="25" Hideable="false">
                            <Commands>
                                <ext:GridCommand CommandName="delete" Icon="Cross">
                                    <ToolTip Text="Delete" />
                                </ext:GridCommand>
                            </Commands>
                            <PrepareToolbar Handler="toolbar.setVisible(!record.newRecord);" />
                        </ext:CommandColumn>
                        <ext:Column ColumnID="GradeName" Width="225" DataIndex="GradeName" Header="GradeName">
                            <Editor>
                                <ext:TextField ID="TextField1" runat="server" AllowBlank="false" />
                            </Editor>
                        </ext:Column>
                        <ext:Column ColumnID="GradeCode" DataIndex="GradeCode" Header="GradeCode">
                            <Editor>
                                <ext:TextField ID="TextField2" runat="server" AllowBlank="false" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                    <Columns>
                             <ext:Column ColumnID="Scale1" DataIndex="Scale1" Header="1" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField12" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale2" DataIndex="Scale2" Header="2" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField1" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale3" DataIndex="Scale3" Header="3" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField2" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale4" DataIndex="Scale4" Header="4" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField3" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale5" DataIndex="Scale5" Header="5" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField4" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale6" DataIndex="Scale6" Header="6" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField5" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale7" DataIndex="Scale7" Header="7" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField6" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale8" DataIndex="Scale8" Header="8" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField7" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale9" DataIndex="Scale9" Header="9" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField8" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale10" DataIndex="Scale10" Header="10" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField9" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale11" DataIndex="Scale11" Header="11" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField10" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ColumnID="Scale12" DataIndex="Scale12" Header="12" Width = "75">
                                <Editor>
                                    <ext:NumberField ID="NumberField11" runat="server" AllowBlank="false" />
                                </Editor>
                            </ext:Column>              
                    </Columns>
                </ColumnModel>
                <TopBar>
                    <ext:Toolbar ID="mainToolbar" runat="server">
                        <Items>
                            <ext:Button ID="btnSave" runat="server" Text="Save" Icon="Disk">
                                <Listeners>
                                    <Click Handler="#{dsSalaryFactor}.save();" />
                                </Listeners>
                            </ext:Button>
                            <ext:Button ID="btnAdd" runat="server" Text="Add" Icon="Add">
                                <Listeners>
                                    <Click Handler="#{GridPanel1}.insertRecord(0, {});#{GridPanel1}.getView().focusRow(0);#{GridPanel1}.startEditing(0, 0);" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarFill ID="ToolbarFill1" runat="server" />
                            <ext:SelectBox ID="cboCriteria" runat="server" EmptyText="Select criteria...">
                                <Items>
                                    <ext:ListItem Text="..." Value="ALL" />
                                    <ext:ListItem Text="GradeCode" Value="GradeCode" />
                                    <ext:ListItem Text="GradeName" Value="GradeName" />
                                </Items>
                            </ext:SelectBox>
                            <ext:ToolbarSpacer ID="ToolbarSpacer2" runat="server" />
                            <ext:TextField ID="txtSearchText" runat="server" AnchorHorizontal="100%" EmptyText="Search..." />
                            <ext:ToolbarSpacer ID="ToolbarSpacer3" runat="server" />
                            <ext:Button ID="btnSearch" runat="server" Text="Search" Icon="Find">
                                <Listeners>
                                    <Click Handler="dsSalaryFactor.reload();" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Plugins>
                    <ext:RowEditor ID="RowEditor1" runat="server" ErrorSummary="false" />
                </Plugins>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                </SelectionModel>
                <View>
                    <ext:GridView>
                    <HeaderGroupRows>
                    <ext:HeaderGroupRow>
                        <Columns>
                            <ext:HeaderGroupColumn Header ="Information" ColSpan = "2" Align="Center"/>
                            <ext:HeaderGroupColumn Header="SalaryScale" ColSpan="8" Align="Center"/>
                        </Columns>
                    </ext:HeaderGroupRow>
                    </HeaderGroupRows>
                    </ext:GridView>
                </View>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="15" />
                </BottomBar>
                <Listeners>
                    <Command Fn="commandHandler" />
                    <BeforeEdit Handler="return !(e.field=='ID' && !e.record.newRecord);" />
                </Listeners>
                <LoadMask ShowMask="true" />
                <SaveMask ShowMask="true" />
            </ext:GridPanel>
            <ext:Hidden ID="hidHasEditPermission" runat="server"></ext:Hidden>
        </Items>
    </ext:Viewport>
</body>
</html>
